package com.mdb.open.epay.service.epay.handle;

import com.mdb.bc.api.data.ResultEx;
import com.mdb.open.epay.feign.OutreachClient;
import com.mdb.open.epay.feign.dto.SMS_9951000;
import com.mdb.open.epay.feign.dto.SMS_9951000_Req;
import com.mdb.open.epay.feign.dto.SMS_Head;
import com.mdb.open.epay.service.epay.handle.dto.SendCoreSMSDto;
import com.mdb.open.epay.utils.NoGenUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Log4j2
@Service
public class CoreSMSHandler {

    @Autowired
    private OutreachClient outreachClient;

    /**
     *
     * 核心發送短信
     * @param dto
     * @return
     */
    public ResultEx sendCoreSMS(SendCoreSMSDto dto) {
        SMS_9951000 sms_9951000 = new SMS_9951000();

        SMS_Head head = new SMS_Head();
        head.setReqRef(NoGenUtil.genReqRef());
        sms_9951000.setHead(head);

        SMS_9951000_Req sms_9951000_req = new SMS_9951000_Req();
        sms_9951000_req.setTransactionType(dto.getTransactionType());
        sms_9951000_req.setSendType(dto.getSendType());
        sms_9951000_req.setPhoneNo(dto.getPhoneNo());
        sms_9951000_req.setEmail(dto.getEmail());
        sms_9951000_req.setCustomerNo(dto.getCustomerNo());
        sms_9951000_req.setAccountNo(dto.getAccountNo());
        sms_9951000_req.setSmsTemplateId(dto.getSmsTemplateId());
        sms_9951000_req.setEmailTemplateId(dto.getEmailTemplateId());
        sms_9951000_req.setSendDate(dto.getSendDate());
        sms_9951000_req.setSendTime(dto.getSendTime());
        sms_9951000_req.setMessageLength(dto.getMessageLength());
        sms_9951000_req.setFiller(dto.getFiller());
        sms_9951000_req.setOpt(dto.getOpt());
        sms_9951000_req.setChannel(dto.getChannel());
        sms_9951000_req.setAction(dto.getAction());
        sms_9951000_req.setCount(dto.getCount());
        sms_9951000_req.setTransactionName(dto.getTransactionName());
        sms_9951000_req.setSmsAccountNo(dto.getSmsAccountNo());
        sms_9951000_req.setCurrency(dto.getCurrency());
        sms_9951000_req.setAmount(dto.getAmount());
        sms_9951000_req.setDate(dto.getDate());
        sms_9951000_req.setTime(dto.getTime());
        sms_9951000_req.setBusinessReference(dto.getBusinessReference());
        sms_9951000_req.setRemark(dto.getRemark());
        sms_9951000_req.setVar01(dto.getVar01());
        sms_9951000_req.setVar02(dto.getVar02());
        sms_9951000_req.setVar03(dto.getVar03());
        sms_9951000_req.setVar04(dto.getVar04());
        sms_9951000_req.setVar05(dto.getVar05());
        sms_9951000_req.setVar06(dto.getVar06());
        sms_9951000_req.setVar07(dto.getVar07());
        sms_9951000_req.setVar08(dto.getVar08());
        sms_9951000_req.setVar09(dto.getVar09());
        sms_9951000_req.setVar10(dto.getVar10());
        sms_9951000.setBody(sms_9951000_req);
        return outreachClient.requestCoreApi9951000(sms_9951000);
    }
}
